package com.wwwarehouse.resource_center.fragment.binding_location_code;

import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.adapter.binding_location_code.SelectBindWarehouseAdapter;
import com.wwwarehouse.resource_center.bean.binding_location_code.SelectBindWarehouseBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiaoke.ni on 2017/10/17.
 */

public class BLCSelectBindWarehouseListFragment extends BaseFragment {

    private RecyclerView mRecyclerView;
    private List<SelectBindWarehouseBean>  mDataList;
    private SelectBindWarehouseAdapter mRvAdapter;
    private static final String KEY_PAGE = "key_page";
    private String page;

    public static BLCSelectBindWarehouseListFragment newInstance(String page, List<SelectBindWarehouseBean>  mDataList) {
        BLCSelectBindWarehouseListFragment fragment = new BLCSelectBindWarehouseListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(KEY_PAGE, page);
        bundle.putParcelableArrayList("details", (ArrayList<? extends Parcelable>) mDataList);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            page = bundle.getString(KEY_PAGE);
            /******需要修改的参数*****/
            mDataList = bundle.getParcelableArrayList("details");
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list_select_bind_warehouse, container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        // findViewById
        mRecyclerView = $(R.id.rv);
        mRvAdapter = new SelectBindWarehouseAdapter(mDataList);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mRecyclerView.setAdapter(mRvAdapter);
    }

    @Override
    public void setTitle() {

    }

    @Override
    public void requestDatas() {

    }
}
